public class ThreadDemo4 {
    public static void main(String[] args) {
        final Object object=new Object();
        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
             synchronized (object){
                 while (true){
                     try {
                         //Thread.sleep(1000);
                         object.wait();
                     } catch (InterruptedException e) {
                         e.printStackTrace();
                     }
                 }
             }
            }
        },"t1");
        t1.start();
        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (object){
                    for (int i = 0; i <10; i++) {
                        System.out.println("hh");

                    }
                }
            }
        },"t2");
        t2.start();
    }
}
